using System;
using System.Collections.Generic;
using System.Text;

namespace Objects
{
    public class NguoiDung
    {
        #region NguoiDung variables

        private int _Id;
        private String _TenNguoiDung;
        private String _TenDangNhap;
        private String _MatKhau;
        private int _Quyen;
        private int _Status;
        private int _SapXep;

        private DateTime _NgayTao;
        private DateTime _LanDangNhapCuoi;

        #endregion

        #region NguoiDung properties

        public int Id
        {
            get { return _Id; }
            set { _Id = value; }
        }

        public String TenNguoiDung
        {
            get { return _TenNguoiDung; }
            set { _TenNguoiDung = value; }
        }

        public String TenDangNhap
        {
            get { return _TenDangNhap; }
            set { _TenDangNhap = value; }
        }

        public String MatKhau
        {
            get { return _MatKhau; }
            set { _MatKhau = value; }
        }

        public int Quyen
        {
            get { return _Quyen; }
            set { _Quyen = value; }
        }

        public int Status
        {
            get { return _Status; }
            set { _Status = value; }
        }

        public int SapXep
        {
            get { return _SapXep; }
            set { _SapXep = value; }
        }

        public DateTime NgayTao
        {
            get { return _NgayTao; }
            set { _NgayTao = value; }
        }

        public DateTime LanDangNhapCuoi
        {
            get { return _LanDangNhapCuoi; }
            set { _LanDangNhapCuoi = value; }
        }

        #endregion

        #region IPopulatable<NguoiDung> Members

        public NguoiDung Populate(System.Data.DataRow reader)
        {
            NguoiDung item = new NguoiDung();

            try { item.Id = Convert.ToInt32(reader["Id"].ToString()); }
            catch { item.Id = -1; }

            item.TenNguoiDung = Convert.ToString(reader["TenNguoiDung"].ToString());
            item.TenDangNhap = Convert.ToString(reader["TenDangNhap"].ToString());
            item.MatKhau = Convert.ToString(reader["MatKhau"].ToString());

            item.NgayTao = Convert.ToDateTime(reader["NgayTao"].ToString());
            item.LanDangNhapCuoi = Convert.ToDateTime(reader["LanDangNhapCuoi"].ToString());

            item.Quyen = Convert.ToInt32(reader["Quyen"].ToString());
            item.Status = Convert.ToInt32(reader["Status"].ToString());
            item.SapXep = Convert.ToInt32(reader["SapXep"].ToString());

            return item;
        }

        #endregion
    }
}
